﻿using Microsoft.Xna.Framework;

namespace Sparklings.RayTracing
{
    public class Segment
    {
        public Vector2 Origin { get; set; }
        public Vector2 End { get; set; }
        public Vector2 Direction { get { return End - Origin; } }
        public Segment(Vector2 origin, Vector2 end)
        {
            Origin = origin;
            End = end;
        }
        public Segment() { }
    }

    /// <summary>
    /// This event handler will be called when a ray hits a segment.
    /// </summary>
    /// <param name="from">The ray that hit.</param>
    /// <param name="segmentHit">The segment that was hit.</param>
    /// <param name="positionHit">The position, relative to the segment origin,
    /// where the segment was hit by the ray.</param>
    public delegate void LightEventHandler(ColoredRay from, LightHittable segmentHit, Vector2 positionHit);

    public class LightHittable : Segment
    {
        public LightHittable(Vector2 origin, Vector2 end, bool isOccluder)
            : base(origin, end)
        {
            IsOccluder = isOccluder;
        }
        public LightEventHandler Hit;
        public bool IsOccluder;
    }
}
